//
//  LHRestaurantDetailViewController.m
//  Knight_Tour
//
//  Created by dlios on 15-5-15.
//  Copyright (c) 2015年 TouchOne. All rights reserved.
//

#import "LHRestaurantDetailViewController.h"
#import "LHRestaurantDetailUserView.h"
#import "MyNavgationView.h"
#import "LHRecommendRestaurantDetailViewController.h"
@interface LHRestaurantDetailViewController ()<JumpToDetailRestaurantDelegate>
@property (nonatomic ,retain) NSMutableArray *recommendRestaurantArr;
@property (nonatomic ,retain) LHRestaurantDetailUserView *RDUV;
@end

@implementation LHRestaurantDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    self.navigationController.navigationBar.hidden = YES;
    [self setAutomaticallyAdjustsScrollViewInsets:NO];
    self.recommendRestaurantArr = [NSMutableArray array];
    [self getManagerWithCover];
    [self createTableView];
    [self createNavigation];
}
- (void)createNavigation
{
    MyNavgationView *myNV = [[MyNavgationView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 64)];
    
    self.navigationController.navigationBar.translucent = NO;
    myNV.leftTarget = self;
    myNV.leftAction = @selector(backToUser);
    [myNV creatLeftButtonWithImage:@"btn_nav_back"];
    
    [myNV creatTitle:@"我的餐馆"];
    [self.view addSubview:myNV];
    [myNV release];
}
- (void) createTableView
{
    self.RDUV = [[LHRestaurantDetailUserView alloc] initWithFrame:CGRectMake(0, 64, LHWidth, LHheight - 64)];
    _RDUV.modelArr = _recommendRestaurantArr;
    self.RDUV.delegate = self;
    [self.view addSubview:_RDUV];
    [_RDUV release];
}

- (void)backToUser
{
    [self.navigationController popViewControllerAnimated:YES];
}

/**
 *  解档方法
 */
-(void) getManagerWithCover
{
    NSString *path = [[[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:@"LHRecommendRestaurantDetai"] stringByAppendingPathComponent:@"LHRecommendRestaurantDetai.kk"];
    self.recommendRestaurantArr = [NSKeyedUnarchiver unarchiveObjectWithFile:path];
}

- (void)JumpToDetailRestaurant:(NSIndexPath *)index
{
    LHRecommendRestaurantDetailViewController *VC = [[LHRecommendRestaurantDetailViewController alloc]init];
    VC.recResMod = self.recommendRestaurantArr[index.row];
    [VC setHidesBottomBarWhenPushed:YES];
    [self.navigationController pushViewController:VC animated:YES];
    [VC release];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
